#!/usr/bin/python

import sys
import itertools

def read_stdin():
    for line in sys.stdin:
        gene_id, inf = line.split()
        genome_id = '_'.join(gene_id.split('_')[:2])
        yield genome_id, float(inf)

for genome_id, grp in itertools.groupby(read_stdin(), lambda i: i[0]):
    infs = [float(inf) for id,inf in grp]
    print "%s\t%s\t%s" % (genome_id, len(infs), sum(infs)/len(infs))

